import math
import numpy as np
INF=math.inf
#11111
# 铁路节点的类
class RailNode():  # 创建上侧节点的类，及其属性（父节点，孩子节点）
    def __init__(self, road, roadlen, id):  # 节点铁路链接目的地，长度，与公路链接，公路长度
        self.id = id
        self.des = []
        self.distance = [0] * 25
        if road is not None:
            self.road = int(road)  # 与下面的哪个节点连接
        else:
            self.road = None
        self.roadlen = roadlen

# 添加铁路函数
def add_rail(a, b, distance):
    a.des.append(b)
    b.des.append(a)
    a.distance[b.id] = distance
    b.distance[a.id] = distance

# 添加节点
m1 = RailNode(2, 3, 1)
m2 = RailNode(3, 2, 2)
m3 = RailNode(None, None, 3)
m4 = RailNode(4, 600, 4)
m5 = RailNode(8, 12, 5)
m6 = RailNode(9, 42, 6)
m7 = RailNode(10, 70, 7)
m8 = RailNode(None,None,8)
m9 = RailNode(None, None, 9)
m10 = RailNode(13, 62, 10)
m11 = RailNode(14, 30, 11)
m12 = RailNode(15, 20, 12)
m13 = RailNode(7, 10, 13)
m14 = RailNode(6, 5, 14)
m15 = RailNode(5, 10, 15)
m16 = RailNode(11, 10, 16)
m17 = RailNode(12, 10, 17)
s1 = RailNode(7, 31, 18)
s2 = RailNode(None, None, 19)
s3 = RailNode(None, None, 20)
s4 = RailNode(None, None, 21)
s5 = RailNode(None, None, 22)
s6 = RailNode(14, 110, 23)
s7 = RailNode(15, 20, 24)

# 添加铁路
add_rail(m1, m3, 450)
add_rail(m2, m3, 80)
add_rail(m3, m4, 1150)
add_rail(m4, m5, 1100)
add_rail(m5, m6, 720)
add_rail(m6, m7, 520)
add_rail(m7, m8, 170)
add_rail(m8, m9, 160)
add_rail(m9, m10, 320)
add_rail(m10, m11, 160)
add_rail(m11, m12, 290)
add_rail(m12, s7, 30)
add_rail(m15, m14, 306)
add_rail(m14, m13, 195)
add_rail(m13, s1, 20)
add_rail(s1, m5, 202)
add_rail(m8, m16, 88)
add_rail(m16, s5, 462)
add_rail(m9, m17, 70)
add_rail(m11, s6, 70)
add_rail(s2, m5, 1200)
add_rail(s3, m6, 690)
add_rail(s4, m8, 690)
# 公路价格
def road_price(mileage):
    return math.ceil(mileage) * 0.1

# 铁路价格
def railway_price(distance):
    if distance == 0:
        return 0
    elif distance <= 300:
        return 20
    elif 301 <= distance <= 350:
        return 23
    elif 351 <= distance <= 400:
        return 26
    elif 401 <= distance <= 450:
        return 29
    elif 451 <= distance <= 500:
        return 32
    elif 501 <= distance <= 600:
        return 37
    elif 601 <= distance <= 700:
        return 44
    elif 701 <= distance <= 800:
        return 50
    elif 801 <= distance <= 900:
        return 55
    elif 901 <= distance <= 1000:
        return 60
    else:
        return 60 + 5 * ((distance - 1000) // 100+1) if (distance - 1000)%100!=0 else 60 + 5 * ((distance - 1000) // 100)

# 要铺设管道的公路长度
rdlen = [104, 301, 750, 606, 194, 205, 201, 680, 480, 300, 220, 210, 420, 500]
#节点列表
nodes=[m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16,m17,s1,s2,s3,s4,s5,s6,s7]
#判断二节点是否联通ab为id
def have_rail(a,b):
    for i in nodes[a-1].des:
        if i==nodes[b-1]:
            return 1
    return 0
# 存储单位最少花费的数组
ans = [[INF] * 16 for _ in range(25)]
#存储路径三维列表
way=np.zeros((8,16,25))
#根据iu打印路径
def rd_print(sid,iu):
    crtnode=sid
    
    while 1:
        flag=1
        for i in range(1,25):
            if iu[i] and have_rail(i,crtnode):
                iu[i]=0
                if crtnode>=18:
                    print("s"+str(crtnode-17)+"->",end="")
                else:
                    print("m"+str(crtnode)+"->",end="")
                crtnode=i
                flag=0
                break
        if flag:
            if crtnode>=18:
                    print("s"+str(crtnode-17))
            else:
                    print("m"+str(crtnode))
            break
            
                
def solve(id, m, a, iu, premiles):
    # 建立列表表示节点是否被使用过【m1-m17,s1-s7]
    iu[m.id] = 1

    if m.road is not None:
        tmp = m.roadlen
        for i in rdlen[(min(a, int(m.road)) - 1):(max(a, int(m.road)) - 1)]:
            tmp += i
        # 计算价格
        price = road_price(tmp) + railway_price(premiles)
        price = round(price, 1)
        if price < ans[id][a]:
            ans[id][a] = price
            way[id-17][a] = iu.copy()
    
    for mm in m.des:
        if iu[mm.id] == 0:
            # 复制 iu 列表
            new_iu = iu.copy()
            solve(id, mm, a, new_iu, premiles + m.distance[mm.id])


for i in [s1, s2, s3, s4, s5, s6, s7]:
    for j in range(1, 16):
        solve(i.id, i, j, [0] * 25, 0) 
for i in ans[18:]:
    print(i[1:])
while 1:
    a=int(input())
    b=int(input())
    rd_print(a+17,way[a][b])
